﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.TongHop.TH_KyGiaVon
{
    public partial class TH_KyGiaVon_ListViewModel : ViewModel<TH_KyGiaVonList>
    {

        public TH_KyGiaVon_ListViewModel(string mode)
        {
            BeginRefresh("GetTH_KyGiaVonList", mode);

        }
        
        public void GetTH_KyGiaVon_ListViewModel(string mode)
        {
            BeginRefresh("GetTH_KyGiaVonList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(TH_KyGiaVonInfo), typeof(TH_KyGiaVon_ListViewModel), null);
        public TH_KyGiaVonInfo SelectedItem
        {
            get { return (TH_KyGiaVonInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteTH_KyGiaVon(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.TH_KyGiaVon.DeleteTH_KyGiaVon(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetTH_KyGiaVonList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
